package com.yazif.vqa.task;

import com.yazif.vqa.api.wechat.domain.Message;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class TargetChain implements Target, InitializingBean {

    @Resource
    @Qualifier("readyTarget")
    private AbstractTarget readyTarget;

    @Resource
    @Qualifier("imageTarget")
    private AbstractTarget imageTarget;

    @Resource
    @Qualifier("ansTarget")
    private AbstractTarget ansTarget;

    private Target target;



    @Override
    public Message execute(Message message) {
        return target.execute(message);
    }


    @Override
    public void afterPropertiesSet() throws Exception {
        readyTarget.setNextTarget(imageTarget);
        imageTarget.setNextTarget(ansTarget);
        this.target = readyTarget;
    }
}
